﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using Newtonsoft.Json;
using System.IO;
using UnityEngine.UI;
using System.Text;

public class EditorFuncs
{

    [MenuItem("Tools/CreatePackageJson")]
    public static void CreatePackageJson()
    {
        PackageConfig packageConfig = new PackageConfig()
        {
            id = "123",
            name = "girls",
            winScalePercent = 0.4f,
            PosX = 1200,
            PosY = 800,
            winAlpha = 128,
            winStyle = enumWinStyle.WinTopAphaPenetrate,
            changeMode = PaperManager.ItemChangeMode.Stanby,
            effecttype = EffectMgr.EffectType.simple_particles,
            isSupportAudioVisual = true,
            audioVisulStrengh = 1,
            isTransparentWhenHover = true
        };
        string jsonStr = JsonConvert.SerializeObject(packageConfig,Formatting.Indented);
        File.WriteAllText("templatePackage.json", jsonStr);
    }

    [MenuItem("Tools/CreateAppJson")]
    public static void CreateAppJson()
    {
        AppConfigData appconfigData = new AppConfigData()
        {
            isEnableEffect = false,
            lastid = "123"
        };
        string jsonStr = JsonConvert.SerializeObject(appconfigData, Formatting.Indented);
        File.WriteAllText("templateAppConfig.json", jsonStr);
    }

    [MenuItem("Tools/ClearPref")]
    public static void ClearPref()
    {
        PlayerPrefs.DeleteAll();
        Debug.Log("删除成功");
    }

    [MenuItem("Tools/ExportUIText")]
    public static void ExportUIText()
    {
        GameObject uiroot = Selection.activeGameObject;
        Text[] texts = uiroot.GetComponentsInChildren<Text>();
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < texts.Length; i++)
        {
            stringBuilder.AppendLine(texts[i].text);
        }

        File.WriteAllText("texts.txt", stringBuilder.ToString());

    }

}
